package $PACKAGE_NAME$.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.web.bindery.event.shared.EventBus;
import $PACKAGE_NAME$.client.place.AppPlaceHistoryMapper;
import $PACKAGE_NAME$.client.place.BasicPlace;
import $PACKAGE_NAME$.client.widget.AppWidget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class $PROJECT_NAME_CLASS_NAME_COMPATIBLE$ implements EntryPoint {

  private final ClientFactory clientFactory = GWT.create(ClientFactory.class);

  private final EventBus eventBus = clientFactory.getEventBus();

  private final PlaceController placeController = clientFactory.getPlaceController();

  public void onModuleLoad() {

    // create the main display region
    AppWidget appDisplay = new AppWidget();

    // create the activity mapper and bind it to the display region
    // AppActivityMapper appActivityMapper = new AppActivityMapper(clientFactory);
    // ActivityManager appActivityManager = new ActivityManager(appActivityMapper, eventBus);
    // appActivityManager.setDisplay(appDisplay.getContainer());

    // start PlaceHistoryHandler with our PlaceHistoryMapper
    AppPlaceHistoryMapper appHistoryMapper = GWT.create(AppPlaceHistoryMapper.class);
    PlaceHistoryHandler placeHistoryHandler = new PlaceHistoryHandler(appHistoryMapper);

    // register the default place
    placeHistoryHandler.register(placeController, eventBus, new BasicPlace());

    RootPanel.get().add(appDisplay);

    // goes to the place represented on URL else default place
    placeHistoryHandler.handleCurrentHistory();

  }

}
